package day01;

import javax.swing.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.text.NumberFormat;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.function.BiConsumer;
import java.util.function.Consumer;

public class ReviewLessons04 {
    public static void main(String[] args) {




        double value = 93.27;
        BigDecimal num = BigDecimal.valueOf(value);
        NumberFormat p1 = NumberFormat.getCurrencyInstance();
        NumberFormat p2 = NumberFormat.getPercentInstance();
        System.out.println(p1.format(num));
        System.out.println(p2.format(num));

        /*
        String s1 = "0.1";
        String s2 = "0.2";
        BigDecimal number1 = new BigDecimal(s1);
        BigDecimal number2 = new BigDecimal(s2);
        System.out.println(number1.add(number2));

         */


        //运算巨大的数字
        String value1 = "120";
        String value2 = "20";
        BigInteger number1 = new BigInteger(value1);
        BigInteger number2 = new BigInteger(value2);
        BigInteger b1 =  number1.add(number2);//加法
        System.out.println(b1);
        BigInteger b2 =  number1.subtract(number2);//减法
        System.out.println(b2);
        BigInteger b3 =  number1.multiply(number2);//乘法
        System.out.println(b3);
        BigInteger b4 =  number1.divide(number2);//除法
        System.out.println(b4);
        BigInteger b5 =  number1.remainder(number2);//求余
        System.out.println(b5);
        BigInteger b6 =  number1.max(number2);//取最大
        System.out.println(b6);
        BigInteger b7 =  number1.min(number2);//取最小
        System.out.println(b7);
        BigInteger[] b8 =  number1.divideAndRemainder(number2);//数组
        System.out.println(b8[0]);//除
        System.out.println(b8[1]);//余

        /*
            Entry 遍历
            keySet 遍历
            foreach遍历
            keySet foreach遍历
         */
        /*
        Map<String,Integer> map = new HashMap<>();
        map.put("张三",18);
        map.put("李四",22);
        map.put("王五",26);
        map.put("赵六",12);
        map.put("孙七",26);

        Set<String> keySet = map.keySet();//keySet 遍历
        for (String e : keySet){
            System.out.println(e+":"+map.get(e));
        }
        System.out.println("--------------------------");
        keySet.forEach(e -> System.out.println(e+":"+map.get(e)));//keySet foreach遍历
        System.out.println("--------------------------");
        map.forEach((e,v) -> System.out.println(e+":"+v));//foreach遍历
        System.out.println("--------------------------");
        Set<Map.Entry<String,Integer>> entrySet = map.entrySet();//Entry 遍历
        for (Map.Entry<String,Integer> e : entrySet){
            String key = e.getKey();
            Integer value = e.getValue();
            System.out.println(key+":"+value);
        }
         */
        /*
        String str = "java表达式";
        byte[] bytes = str.getBytes(StandardCharsets.UTF_8);
        String s = new String(bytes,StandardCharsets.UTF_8);
        System.out.println(s);

        for (int i = 0;i<str.length();i++){
            char c = str.charAt(i);
            System.out.println(c+":"+Integer.toBinaryString(c));
        }

        for (byte b : bytes){
            System.out.println(Integer.toBinaryString(b&0xff));
        }
         */
        /*
        int[] a = {345,213,234,456,234,213,56,679,34,234,52,666,333,888,555};
        System.out.println(Arrays.toString(a));
        for (int i = 0; i < a.length-1; i++) {
            boolean b1 = false;
            for (int j = 0; j < a.length-1-i; j++) {
                if (a[j]>a[j+1]){
                    int b = a[j];
                    a[j] = a[j+1];
                    a[j+1] = b;
                    b1 = true;
                }
            }
            System.out.println(Arrays.toString(a));
        }
         */
    }
}
